import request from '@/utils/request'

// 查询微信授权日志列表
export function listWxAuthLog(query) {
  return request({
    url: '/wx/authlog/list',
    method: 'get',
    params: query
  })
}

// 查询微信授权日志详细
export function getWxAuthLog(id) {
  return request({
    url: '/wx/authlog/' + id,
    method: 'get'
  })
}

// 新增微信授权日志
export function addWxAuthLog(data) {
  return request({
    url: '/wx/authlog',
    method: 'post',
    data: data
  })
}

// 修改微信授权日志
export function updateWxAuthLog(data) {
  return request({
    url: '/wx/authlog',
    method: 'put',
    data: data
  })
}

// 删除微信授权日志
export function delWxAuthLog(id) {
  return request({
    url: '/wx/authlog/' + id,
    method: 'delete'
  })
}

// 根据openid查询授权日志
export function getWxAuthLogByOpenid(openid) {
  return request({
    url: '/wx/authlog/openid/' + openid,
    method: 'get'
  })
}

// 根据授权类型查询授权日志
export function getWxAuthLogByAuthType(authType) {
  return request({
    url: '/wx/authlog/type/' + authType,
    method: 'get'
  })
}

// 根据授权结果查询授权日志
export function getWxAuthLogByAuthResult(authResult) {
  return request({
    url: '/wx/authlog/result/' + authResult,
    method: 'get'
  })
}

// 统计授权成功次数
export function countSuccessAuthByOpenid(openid) {
  return request({
    url: '/wx/authlog/stats/success/' + openid,
    method: 'get'
  })
}

// 统计授权失败次数
export function countFailedAuthByOpenid(openid) {
  return request({
    url: '/wx/authlog/stats/failed/' + openid,
    method: 'get'
  })
}

// 清理过期日志
export function cleanExpiredLogs(days) {
  return request({
    url: '/wx/authlog/clean/' + days,
    method: 'post'
  })
} 